<?php
    header('Content-type:text/html;charset=utf-8');

//if($a>=90&&$b>=90){
//    echo '三好学生';
//}else{
//    echo '不是三好学生';
//}
//$a>=90&&$b>=90 ? 'echo 三好学生 ': "echo \'三好学生\'";
//if($a>=90||$b>=90){
//    echo '三好学生';
//}else{
//    echo '不是三好学生';

    if(isset($_POST['button'])){
        $cnscore=$_POST['cnscore'];
        $mathscore=$_POST['mathscore'];
        if($cnscore='' || !is_numeric($cnscore) ||$cnscore<0||$cnscore>100){
            echo "{$cnscore}须是正整数或不可超过范围";
        }
        elseif ($mathscore='' || !is_numeric($mathscore) ||$mathscore<0||$mathscore>100){
            echo "{$mathscore}须是正整数或不可超过范围";
        }
        else{
            $cnscore=$_POST['cnscore'];
            $mathscore=$_POST['mathscore'];
            $avg = ( $cnscore+$mathscore)/2;

            if($avg>=90){
                echo '优秀';
            }
            elseif ($avg>=80&$avg<90){
                echo '不赖';
            }
            elseif($avg>=70&$avg<80){
                echo '加油';
            }
            elseif($avg>=60&$avg<70){
                echo '及格';
            }
            else{
                echo '真菜';
            }
        }
    }

?>
<form method="post" action="">
    语文成绩：<input type="text" name="cnscore" ><br>
    数学成绩：<input type="text" name="mathscore"><br>
    判断成绩：<input type="submit" name="button" value="判断成绩">
</form>

